package com.longlong.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("admin_user")
public class AdminUser implements UserDetails {


    @TableId(type = IdType.AUTO)
    private Integer id;

    private String userName;


    private String password;

    private boolean state;


    /*
     * 用户对应的角色列表
     * */
    private List<AdminRole> adminRoles;

    /*
     * 用户根据角色获取的菜单列表
     * */
    private List<AdminMenu> adminMenus;

    /*
     * 用户根据角色获取对应的权限列表
     * */
    private List<AdminPermission> adminPermissions;


    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;





    /*
    * 权限数据
    * */
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    /*
    * 用户名
    * */
    @Override
    public String getUsername() {
        return userName;
    }

    /*
    *
    * */
    @Override
    public String getPassword() {
        return password;
    }


    /*
    * 账号是否过期
    * */
    @Override
    public boolean isAccountNonExpired() {
        return false;
    }


    /*
    * 账号是否被锁定
    * */
    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    /*
    * 是否被禁用
    * */
    @Override
    public boolean isEnabled() {
        return state;
    }
}


